#include <iostream>
#include "basic/basic.h"
#include "process/processor.h"

void test_timer(){
	std::cout << "testTimer " << boost::this_thread::get_id() << std::endl;
}

class TestTimerCls{
public:
	void test(){
		std::cout << "TestTimerCls::test " << boost::this_thread::get_id() << std::endl;
	}
};

int main() {
	{	// 测试并发编程
		eyas::process::init();
		std::cout << "Enter test the timer, the second Enter cancel the timer." << std::endl;
		getchar();
		eyas::process::timer_ptr timer_ptr1 = eyas::process::fly_timer(1000, 1000, &test_timer);
		eyas::process::timer_ptr timer_ptr2 = eyas::process::fly_timer(1000, 1000, &TestTimerCls::test, boost::shared_ptr<TestTimerCls>(new TestTimerCls()));
		getchar();
		timer_ptr1->cancel();
		timer_ptr1->cancel();
		std::cout << "timer is canceled." << std::endl;
	}
	std::cout << "Enter exit the test." << std::endl;
	getchar();
	return 0;
}
